﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Krile.Forms.ConfigForm.Children
{
    public partial class Renderer : Krilib.Control.ConfigPage
    {
        public Renderer()
        {
            InitializeComponent();
        }

        private void Renderer_Load(object sender, EventArgs e)
        {
            UserNameArea.Value = Core.Config.Appearance.Renderer.UserNameArea;
            UseListMiniIcon.Checked = Core.Config.Appearance.Renderer.UseListMiniIcon;
            ShowUserId.Checked = Core.Config.Appearance.Renderer.ShowUserId;
            UserNameCentering.Checked = Core.Config.Appearance.Renderer.UserNameCentering;
            NameAbove.Checked = Core.Config.Appearance.Renderer.NameAbove;
            TooltipNewlineCount.Value = Core.Config.Appearance.Renderer.TooltipNewlineCount;
            widthSample.Width = (int)UserNameArea.Value;
            linebreakSample.Text = lbsOrigText.Substring(0, (int)TooltipNewlineCount.Value);
        }

        public override void Apply()
        {
            Core.Config.Appearance.Renderer.UserNameArea = (int)UserNameArea.Value;
            Core.Config.Appearance.Renderer.UseListMiniIcon = UseListMiniIcon.Checked;
            Core.Config.Appearance.Renderer.ShowUserId = ShowUserId.Checked;
            Core.Config.Appearance.Renderer.UserNameCentering = UserNameCentering.Checked;
            Core.Config.Appearance.Renderer.NameAbove = NameAbove.Checked;
            Core.Config.Appearance.Renderer.TooltipNewlineCount = (int)TooltipNewlineCount.Value;
            base.Apply();
        }

        private void UserNameArea_ValueChanged(object sender, EventArgs e)
        {
            widthSample.Width = (int)UserNameArea.Value;
        }

        const string lbsOrigText = "This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. This is line-break sample text. ";
        private void TooltipNewlineCount_ValueChanged(object sender, EventArgs e)
        {
            linebreakSample.Text = lbsOrigText.Substring(0, (int)TooltipNewlineCount.Value);
        }
    }
}
